$(document).ready(function () {
    //$('#myModal').modal('toggle');
    /**
     * 初始化
     */
    toastr.options = {
        "closeButton": true,
        "debug": false,
        "progressBar": true,
        "preventDuplicates": false,
        "positionClass": "toast-top-right",
        "onclick": null,
        "showDuration": "400",
        "hideDuration": "1000",
        "timeOut": "3000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    };

    $("#loginBtn").click(function () {
        var userName = $("#userName").val();
        var pwd = $("#pwd").val();
        $.ajax({
            type: "POST",
            url: "/service/user/login",
            data: {
                "username": userName,
                "password": pwd
            },
            success: function (res) {
                if (res.code === "suc") {
                    window.location.href = "/";
                } else {
                    toastr.error("用户名或密码错误");
                }
            }
        });
    });
});